package xFGE.Loader
{
	import flash.net.URLRequest;
	
	
	/**
	 * 载入资源的统一结构体
	 * @author Ben
	 * @version 1.0
	 * @updated 27-三月-2009 11:24:47
	 */
	public class ResourceObj extends Object
	{
	    /**
	     * 资源名
	     */
	    private var _name: String;
	    /**
	     * 资源类型
	     */
	    private var _type: String;
	    /**
	     * 资源地址
	     */
	    private var _url: URLRequest;
	    /**
	     * 重试次数
	     */
	    private var _retry: int;
	    /**
	     * 是否失败资源
	     */
	    private var _failed: Boolean = false;
	    /**
	     * 资源数据
	     */
	    private var _content:*;
	    /**
	     * 载入完成时是否回调
	     */
	    private var _isCallBack: Boolean;
	    /**
	     * swf绑定类的名字
	     */
	    private var _swfClassName: String;
	    /**
	     * 载入进度
	     */
	    private var _loadedPresent: Number = 0;
	    /**
	     * 载入即时速度
	     */
	    private var _loadedSpeed: int;

		
		public function ResourceObj(name:String,type:String,url:URLRequest,isCallBack:Boolean = false,swfClassName:String = null)
		{
			//TODO: implement function
			this._name = name;
			this._type = type;
			this._url  = url;
			this._isCallBack = isCallBack;
			this._swfClassName = swfClassName;
		}

		/**
		 * 资源名
		 */
		public function get name(): String
		{
			return _name;
		}

		/**
		 * 资源名
		 * 
		 * @param newVal
		 */
		public function set name(newVal:String): void
		{
			_name = newVal;
		}

		/**
		 * 资源类型
		 */
		public function get type(): String
		{
			return _type;
		}

		/**
		 * 资源类型
		 * 
		 * @param newVal
		 */
		public function set type(newVal:String): void
		{
			_type = newVal;
		}

		/**
		 * 资源地址
		 */
		public function get url(): URLRequest
		{
			return _url;
		}

		/**
		 * 资源地址
		 * 
		 * @param newVal
		 */
		public function set url(newVal:URLRequest): void
		{
			_url = newVal;
		}

		/**
		 * 重试次数
		 */
		public function get retry(): int
		{
			return _retry;
		}

		/**
		 * 重试次数
		 * 
		 * @param newVal
		 */
		public function set retry(newVal:int): void
		{
			_retry = newVal;
		}

		/**
		 * 是否失败资源
		 */
		public function get failed(): Boolean
		{
			return _failed;
		}

		/**
		 * 是否失败资源
		 * 
		 * @param newVal
		 */
		public function set failed(newVal:Boolean): void
		{
			_failed = newVal;
		}

		/**
		 * 资源数据
		 */
		public function get content(): *
		{
//			//如果是不是SWF类型，或者该SWF读取为读取该SWF类
//			if(_type != xLoader.LOADER_TYPE_SWF ||  !(_content is MovieClip)) return _content;
//			return null;
			return _content;
		}

		/**
		 * 资源数据
		 * 
		 * @param newVal
		 */
		public function set content(newVal:*): void
		{
			_content = newVal;
		}

		/**
		 * 载入完成时是否回调
		 */
		public function get isCallBack(): Boolean
		{
			return _isCallBack;
		}

		/**
		 * 载入完成时是否回调
		 * 
		 * @param newVal
		 */
		public function set isCallBack(newVal:Boolean): void
		{
			_isCallBack = newVal;
		}

		/**
		 * swf绑定类的名字
		 */
		public function get swfClassName(): String
		{
			return _swfClassName;
		}

		/**
		 * swf绑定类的名字
		 * 
		 * @param newVal
		 */
		public function set swfClassName(newVal:String): void
		{
			_swfClassName = newVal;
		}

		/**
		 * 载入进度
		 */
		public function get loadedPresent(): Number
		{
			return _loadedPresent;
		}

		/**
		 * 载入进度
		 * 
		 * @param newVal
		 */
		public function set loadedPresent(newVal:Number): void
		{
			_loadedPresent = newVal;
		}

		/**
		 * 载入即时速度
		 */
		public function get loadedSpeed(): int
		{
			return _loadedSpeed;
		}

		/**
		 * 载入即时速度
		 * 
		 * @param newVal
		 */
		public function set loadedSpeed(newVal:int): void
		{
			_loadedSpeed = newVal;
		}
	}
}